﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>任务待办</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Cache-Control" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <!-- Bootstrap -->
    <link href="/CSS/bootstrap3.3.5/css/bootstrap.css" rel="stylesheet">
    <link href="/CSS/font-awesome-4.3.0/css/font-awesome.min.css" rel="stylesheet">
    <link href="/CSS/Base/BaseClass.css" rel="stylesheet" type="text/css" />
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <link href="/CSS/font-awesome-4.3.0/css/font-awesome.min.css" rel="stylesheet">
    <style>
        blockquote:hover {
            border-color: #66c9f3;
            box-shadow: 0 0 10px #66c9f3;
        }

        .mangdb {
            visibility: collapse;
        }

        .pldate {
            visibility: collapse;
        }

        blockquote:hover .mangdb {
            visibility: visible;
        }

        .plspan:hover .pldate {
            visibility: visible;
        }
    </style>
</head>
<body>
    <div class="container-fluid maindiv" style="margin-top: 20px" id="dvContent" ms-controller="APP_RCTX">
        <div style="width:200px;position:absolute">
            <div class="panel panel-default">
                <div class="panel-body text-center">
                    <a href="#" ms-click="addRCTX()" id="btADD" style=" height: 34px;line-height: 34px;" class="button button-glow button-border button-rounded button-primary"><i class="fa fa-plus"></i>任务待办</a>
                </div>
            </div>
            <div class="list-group ">
                <a href="/View/APPBaseView/APP_RCTX.html" class="list-group-item  active" style="padding-left: 15px"><span class="glyphicon glyphicon-list-alt"></span>&nbsp;&nbsp;我的任务<span class="badge"></span></a>
            </div>
        </div>
        <div class="row" style="margin-left:211px">
            <div class="col-xs-12 contentdv">

                <!-- Nav tabs -->
                <ul class="nav nav-tabs" role="tablist">
                    <li role="presentation" class="active"><a href="#zzjx" aria-controls="zzjx" role="tab" data-toggle="tab" ms-click="getstartrcdata('0')">正在进行<span class="badge" ms-text="startCount" ms-if="startCount>0"></span></a></li>
                    <li role="presentation"><a href="#yjs" aria-controls="yjs" role="tab" data-toggle="tab" ms-click="getendrcdata('0')">已结束<span class="badge" ms-text="endCount" ms-if="endCount>0"></span></a></li>
                </ul>
                <!-- Tab panes -->
                <div class="tab-content">
                    <div role="tabpanel" class="tab-pane active" id="zzjx">

                        <div class="btn-group" role="group" style=" margin-top: 20px;">
                            <button type="button" class="btn btn-default" ms-class="active:selstartType=='0'" ms-click="getstartrcdata('0')">全部</button>
                            <button type="button" class="btn btn-default" ms-class="active:selstartType=='1'" ms-click="getstartrcdata('1')">我创建的</button>
                            <button type="button" class="btn btn-default" ms-class="active:selstartType=='2'" ms-click="getstartrcdata('2')">我负责的</button>
                            <button type="button" class="btn btn-default" ms-class="active:selstartType=='3'" ms-click="getstartrcdata('3')">我参与的</button>
                        </div>
                        
                            <blockquote style="padding: 5px 10px; border-left: 3px solid #8bc4ea; font-size: 14px; margin-top: 20px; margin-bottom: 10px;" ms-repeat-el="CommonData">
                                <p style="margin-bottom: 0; font-weight: bold; padding-bottom: 4px;" ms-on-click="enterDB(el,this)">
                                    <span style="color: brown;">【{{el.LeiBie}}】{{el.RWTitle}}</span>
                                    <span class="badge" style="padding: 1px 3px; background-color: darkolivegreen;" title="评论数量" ms-if="el.PLList.size()!=0">{{el.PLList.size()}}</span>
                                </p>
                                <div style="min-height: 20px;">
                                    负责人: <span class="badge">{{ComFunJS.convertuser(el.RWFZR)}} </span>
                                    <span ms-if="el.RWCYR.length>0">参与人</span><span class="badge" ms-repeat-user="el.RWCYR.split(',')">{{ComFunJS.convertuser(user) }}</span>
                                    <span style="margin-top: 4px; color: darkgray;" ms-if="el.PLList.size()!=0">【{{el.PLList[el.PLList.size()-1].CRUserName}}】：{{ComFunJS.convstr(el.PLList[el.PLList.size()-1].MSGContent,20)}}</span>
                                    <span style="margin-top: 2px; float: right" ms-if="el.CRUser!=username">创建人：<b style="color: brown;">{{  ComFunJS.convertuser(el.CRUser)}}</b></span>
                                    <span class="mangdb pull-right">
                                        <label style="margin-bottom: 0" ms-if="el.CRUser==username" ms-click="inputevent(event)">
                                            <input ms-on-click="completeDB(el,event,this)" type="checkbox" class="isjs" style="vertical-align: middle; vertical-align: middle; margin-top: 0; width: 14px; height: 14px;">结束
                                        </label><a href="#" class="delTX" style="margin-left: 10px;" ms-if="el.CRUser==username" ms-click="deltx(el,event)">删除</a><a href="#" class="UpTX" style="margin-left: 10px;" ms-attr-dataid="el.ID" ms-attr-dbnr="el.Name" ms-attr-leibie="el.LeiBie" ms-attr-txdate="el.TXTime" ms-click="ModityRCTX(el.ID)" ms-attr-txr="el.TXUser" ms-visible="el.CRUser==username">修改待办事项</a>
                                    </span>
                                </div>
                                <div style="display: none; margin-top: 6px;" class="dbztinfo">
                                    <span style="margin-top: 4px;" ms-if="el.TXTime">
                                        <img src="/images/tmp-img2.png" class="viewdb" style="width: 16px; height: 16px; margin-left: 4px;" />{{el.TXTime|date("yy年MM月dd日 HH:mm")}}
                                    </span>
                                    <span class="plspan" ms-repeat-item="el.PLList" style="padding-bottom: 6px; padding-top: 6px; font-size: 14px; color: darkgray; display: block; border-bottom: 1px dotted whitesmoke;">【{{item.CRUserName}}】：{{item.MSGContent}}<span style="float: right" class="pldate">{{item.CRDate|date("MM月dd日 HH:mm")}}</span></span>
                                    <div class="input-group" style="margin-top: 10px;">
                                        <input type="text" class="form-control plnr" placeholder="此处输入执行状态（按Ctrl+Enter直接提交）" ms-keypress="jptj(el,this,event)" aria-describedby="sizing-addon3" ms-on-click="inputevent(event)">
                                        <span class="input-group-addon btnaddPL" id="sizing-addon3" ms-on-click="addPL(el,this,event)">+添加</span>
                                    </div>
                                </div>
                            </blockquote>
                        

                        
                    </div>
                    <div role="tabpanel" class="tab-pane" id="yjs">
                        <div class="btn-group" role="group" style="margin-top: 20px;">
                            <button type="button" class="btn btn-default" ms-class="active:selendType=='0'" ms-click="getendrcdata('0')">全部</button>
                            <button type="button" class="btn btn-default" ms-class="active:selendType=='1'" ms-click="getendrcdata('1')">我创建的</button>
                            <button type="button" class="btn btn-default" ms-class="active:selendType=='2'" ms-click="getendrcdata('2')">我负责的</button>
                            <button type="button" class="btn btn-default" ms-class="active:selendType=='3'" ms-click="getendrcdata('3')">我参与的</button>
                        </div>
                        <blockquote style="padding: 5px 10px; border-left: 3px solid #8bc4ea; font-size: 14px; margin-top: 20px; margin-bottom: 10px;" ms-repeat-el="endrcdata">
                            <p style="margin-bottom: 0; font-weight: bold; padding-bottom: 4px;" ms-on-click="enterDB(el,this)">
                                <span style="color: brown;">【{{el.LeiBie}}】{{el.RWTitle}}</span>
                                <span class="badge" style="padding: 1px 3px; background-color: darkolivegreen;" title="评论数量" ms-if="el.PLList.size()!=0">{{el.PLList.size()}}</span>
                            </p>
                            <div style="min-height: 20px;">
                                <span style="float: right" >创建人：<b style="color: brown;">{{  ComFunJS.convertuser(el.CRUser)}}</b></span>
                            </div>
                            <div style=" margin-top: 6px;">
                                <span class="badge" ms-repeat-user="el.RWCYR.split(',')">{{ComFunJS.convertuser(user)}}</span>
                                <span style="margin-top: 4px;" ms-if="el.TXTime">
                                    <img src="/images/tmp-img2.png" class="viewdb" style="width: 16px; height: 16px; margin-left: 4px;" />{{el.TXTime|date("yy年MM月dd日 HH:mm")}}
                                </span>
                                <span class="plspan" ms-repeat-item="el.PLList" style="padding-bottom: 6px; padding-top: 6px; font-size: 14px; color: darkgray; display: block; border-bottom: 1px dotted whitesmoke;">【{{item.CRUserName}}】：{{item.MSGContent}}<span style="float: right" class="pldate">{{item.CRDate|date("MM月dd日 HH:mm")}}</span></span>
                            </div>
                        </blockquote>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="/Scripts/jquery-1.11.2.min.js"></script>
    <script src="/Scripts/avalon.js"></script>
    <script src="/Scripts/jquery-migrate-1.1.0.min.js"></script>
    <script src="/CSS/bootstrap3.3.5/js/bootstrap.min.js"></script>
    <script src="/Scripts/SZHLCommon.js"></script>
    <script>
        var model = avalon.define({
            $id: "APP_RCTX",
            username: ComFunJS.getnowuser(),
            selstartType: "",
            selendType: "",
            startCount: "0",
            endCount: "0",
            CommonData: [],//日程数据
            endrcdata: [],//日程数据
            addRCTX: function () {
                parent.ComFunJS.winviewform("/View/APPBaseView/APP_ADD.html?FormCode=RCTXADD&FrameName=frameRCTX", "添加数据", "1000", "");
            },
            ModityRCTX: function (Id) {
                parent.ComFunJS.winviewform("/View/APPBaseView/APP_ADD.html?FormCode=RCTXADD&FrameName=frameRCTX&ID=" + Id, "添加数据", "1000", "");
            },
            deltx: function (el, event) {
                event.stopPropagation();
                parent.ComFunJS.winconfirm('你确定要删除此待办吗？', function () {
                    $.getJSON("/API/FTAPI.ashx?Action=DELRWDB", { P1: el.ID }, function (resultData) {
                        if (resultData.ErrorMsg == "") {
                            model.CommonData.remove(el);
                            parent.ComFunJS.winsuccess('删除成功');
                        }

                    });
                }, function () { })
            },
            enterDB: function (el, dom) {
                if ($(dom).parent().find('.dbztinfo').is(":hidden")) {
                    $('.dbztinfo').hide('fast');
                    $(dom).parent().find('.dbztinfo').show('fast')
                } else {
                    $(dom).parent().find('.dbztinfo').hide('fast')
                }

            },
            inputevent: function (event) { //输入框事件
                event.stopPropagation();
            },
            addPL: function (el, dom, event) {
                if (event) {
                    event.stopPropagation();
                }
                var content = $(dom).parent().find(".plnr").val();
                if (content == "") {
                    toastr.error('内容不能为空哦')
                } else {
                    $.post('/API/FTAPI.ashx?Action=ADDCOMENT', { "P1": content, "MsgType": "RCTX", "MsgLYID": el.ID }, function (result) {
                        var result = $.parseJSON(result);
                        if (result.ErrorMsg == "") {
                            el.PLList.push(result.Result)
                            $(dom).parent().find(".plnr").val("")
                        }
                    })
                }

            },
            completeDB: function (el, event, dom) {//修改待办状态
                event.stopPropagation();
                var ISComplete = dom.checked ? "1" : "0";
                if (ISComplete == "1") {
                    $(dom).parent().parent().parent().parent().css({ background: "paleturquoise" });
                } else {
                    $(dom).parent().parent().parent().parent().css({ background: "transparent" });
                }
                $.getJSON('/API/FTAPI.ashx?Action=COMPLETERCTX', { "P1": el.ID, "P2": ISComplete }, function (result) {
                    if (result.ErrorMsg == "") {
                        parent.ComFunJS.winsuccess("操作成功");
                    }
                })
            },
            //键盘提交事件
            jptj: function (el, dom, event) {
                if (event.ctrlKey && (event.keyCode == 13 || event.keyCode == 10)) {
                    var btn = $(dom).parent().find(".btnaddPL")[0];
                    model.addPL(el, btn);

                }
            },
            getstartrcdata: function (type) {
                if (type == model.selstartType) {
                    return;
                }
                model.selstartType = type;
                $.getJSON("/API/FTAPI.ashx?Action=GETRCTXDATA", { P1: 0, P2: type }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        model.CommonData = resultData.Result;
                        if (type == '0') {
                            model.startCount = model.CommonData.length;
                        }
                    }

                });
            },
            getendrcdata: function (type) {
                if (type == model.selendType) {
                    return;
                }
                model.selendType = type;
                $.getJSON("/API/FTAPI.ashx?Action=GETRCTXDATA", { P1: 1, P2: type }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        model.endrcdata = resultData.Result;
                        if (type == '0') {
                            model.endCount = model.endrcdata.length;
                        }
                    }

                });
            }

        })
        avalon.ready(function () {
            ComFunJS.initsetajax();
            model.getstartrcdata('0');//默认列表为正在进行
            model.getendrcdata('0');//加载已结束数据
        })
    </script>
</body>
</html>
